<template>
    <div class="le">
        <div class="header">学生分布情况</div>
        <div class="body" ref="chart">

        </div>
    </div>
</template>

<script setup lang="ts">
import * as echarts from 'echarts';
import { ref, onMounted, onBeforeMount } from 'vue';

const chart = ref<HTMLElement | null>(null);
onMounted(() => {
    if (chart.value) {
        const myChart = echarts.init(chart.value)
        myChart.setOption({
            title: {
                text: 'Stacked Line'
            },
            tooltip: {
                trigger: 'axis'
            },
            legend: {
                data: ['Email', 'Union Ads', 'Video Ads', 'Direct', 'Search Engine']
            },
            grid: {
                left: '3%',
                right: '4%',
                bottom: '3%',
                containLabel: true
            },
            toolbox: {
                feature: {
                    saveAsImage: {}
                }
            },
            xAxis: {
                type: 'category',
                boundaryGap: false,
                data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
            },
            yAxis: {
                type: 'value'
            },
            series: [
                {
                    name: 'Email',
                    type: 'line',
                    stack: 'Total',
                    data: [120, 132, 101, 134, 90, 230, 210],
                    smooth: true, // 将折线变成曲线,
                    showSymbol: false // 不显示曲线上的节点
                },
                {
                    name: 'Union Ads',
                    type: 'line',
                    stack: 'Total',
                    data: [220, 182, 191, 234, 290, 330, 310],
                    smooth: true, // 将折线变成曲线
                    showSymbol: false // 不显示曲线上的节点
                },
                {
                    name: 'Video Ads',
                    type: 'line',
                    stack: 'Total',
                    data: [150, 232, 201, 154, 190, 330, 410],
                    smooth: true, // 将折线变成曲线
                    showSymbol: false // 不显示曲线上的节点
                },
                {
                    name: 'Direct',
                    type: 'line',
                    stack: 'Total',
                    data: [320, 332, 301, 334, 390, 330, 320],
                    smooth: true, // 将折线变成曲线
                    showSymbol: false // 不显示曲线上的节点
                },
                {
                    name: 'Search Engine',
                    type: 'line',
                    stack: 'Total',
                    data: [820, 932, 901, 934, 1290, 1330, 1320],
                    smooth: true, // 将折线变成曲线
                    showSymbol: false // 不显示曲线上的节点
                }
            ]
        })
    }
})


</script>

<style lang="scss" scoped>
.le {
    width: 100%;
    height: 100%;
    //   padding: 100px 50px;
    padding-left: 140px;
}

.header {
    width: 75%;
    height: 8%;
    background: url("@/assets/image/左.png") no-repeat;
    background-size: 97% 100%;
    color: white;
    font-weight: 800;
    display: flex;
    align-items: center;
    padding-left: 30px;
}

.body {
    width: 75%;
    height: 65%;
    margin-top: 30px;
    background-color: rgba(12, 29, 95, .8);
}
</style>